package com.mao.proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class SmsProxyHandler implements InvocationHandler {

    Object target;

    public SmsProxyHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(proxy.getClass());
        beforeMethod();
        Object invoke = method.invoke(target, args);
        afterMethod();
        return  invoke;
    }

    private void afterMethod() {
        System.out.println("we can do something after the method ");

    }

    private void beforeMethod() {
        System.out.println("we can do something before the method ");
    }


}
